home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Technology Seed / Mac Tech Seed Feb '96 / Mac Tech Seed Feb '96.toast / pc / develop / include / qtcodec.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-08  |  17.5 KB  |  438 lines

  1.  
  2.  
  3. // ---------------------------------------------------------------------
  4. //
  5. // QTCODEC.H - QuickTime for Windows C and C++ Bindings
  6. //
  7. //             Version 2.0
  8. //
  9. //             (c) Copyright 1988-1994 Apple Computer, Inc. All Rights Reserved.
  10. //
  11. // ---------------------------------------------------------------------
  12.  
  13.  
  14. #if !defined __QTCODEC_H
  15. #define __QTCODEC_H
  16.  
  17. // Header files
  18. #include <qtw.h>
  19. #include <compmgr.h>
  20.  
  21. // Macros
  22. #ifdef _WIN32
  23.     #define FIELDOFFSET(type, field)    ((int)(&((type NEAR*)1)->field)-1)
  24. #endif
  25. #define ADDOFFSET(a,b) (LPBYTE)((char HUGE *)(a)+(b))
  26. #define SUBOFFSET(a,b) (LPBYTE)((char HUGE *)(a)-(b))
  27. #define HUGESUM(a,b,c) ADDOFFSET(a,FIELDOFFSET(b,c))
  28. #define ROUNDUP(a,b) (((a)+(b-1))&(~(b-1)))
  29. #define ROUNDDOWN(a,b) ((a)&(~(b-1)))
  30. #define ROUNDDOWNSLOW(a,b) ((a)-((a)%(b)))
  31. #define LOCAL static NEAR
  32. #define GlobalDeref(a) GlobalLock(a)
  33.  
  34. // 16-bit macro to determine if we are running on Windows 95
  35. #ifndef _WIN32
  36.     #define OS_WINNT 0x04
  37.     #define bThisIsWin95() \
  38.         (((GetWinFlags() >> 12) != OS_WINNT) \
  39.         && (GetProcAddress(GetModuleHandle("KRNL386.EXE"), "REGSETVALUEEX") != NULL))
  40. #endif
  41.  
  42.  
  43. // Data types
  44. typedef short * PSHORT ;
  45. typedef short FAR * LPSHORT ;
  46. typedef BOOL * PBOOL ;
  47. typedef BOOL FAR * LPBOOL ;
  48. #ifndef _WIN32
  49.     #define HUGE _huge
  50. #else
  51.     #define HUGE
  52. #endif
  53. typedef char HUGE * HPSTR ;
  54. typedef unsigned char HUGE * HPBYTE ;
  55. typedef void HUGE * HPVOID ;
  56. typedef LONG HUGE * HPLONG ;
  57. typedef WORD ( FAR CDECL * HDWDISP)( ...) ;
  58.  
  59. // Data
  60. enum VID_DISPATCH { VDSP_SETBANK      =  1
  61.           , VDSP_SLIDEWINDOW  =  2
  62.           , VDSP_SAVECONTEXT  =  3
  63.           , VDSP_RESTCONTEXT  =  4
  64.           , VDSP_SETTARGET    =  5
  65.           , VDSP_IDENTIFY     = 21
  66.           , VDSP_VERSION      = 22
  67.           , VDSP_BANKTABLE    = 23
  68.           , VDSP_BITBLTTYPE   = 24
  69.           , VDSP_SCANWIDTH    = 25
  70.           , VDSP_LINEAR_BUF   = 26
  71.           , VDSP_READWRITE    = 41
  72.           , VDSP_TERMINATE    = 86
  73.           } ;
  74. enum OPT_TYPE { OPT_UNINIT = 0              // field uninitialized
  75.           , OPT_RAW    = 1              // decompress to raw buffer
  76.           , OPT_BMP    = 2              // decompress to BMP
  77.           , OPT_HDW    = 3              // decompress to video adapter
  78.           } ;
  79. enum BMP_TYPE { BMP_NONE      =  0          // unknown type
  80.           , BMP_DIB       =  1          // DIB
  81.           , BMP_MONO      =  2          // monochrome
  82.           , BMP_PACKED_4  =  3          // packed 4 bit, e.g., Fahrenheit
  83.           , BMP_PLANAR_4  =  4          // VGA or SVGA
  84.           , BMP_INDEX_8   =  5          // palettized driver
  85.           , BMP_5_5_5     =  6          // 32,768 colors
  86.           , BMP_5_6_5     =  7          // XGA, Intel order
  87.           , BMP_PLANAR_16 =  8          // two planes of one byte each
  88.           , BMP_8_8_8_RGB =  9          // true color RGB
  89.           , BMP_MEMERR    = 10          // insufficient memory for buffers
  90.           , BMP_8_8_8_BGR = 11          // true color BGR
  91.           , BMP_5_6_5_M   = 12          // XGA, Motorola order
  92.           , BMP_aRGB32    = 13          // 32-bit with alpha channel
  93.           , BMP_RGBa32    = 14          // 32-bit with alpha channel
  94.           , BMP_aBGR32    = 15          // 32-bit with alpha channel
  95.           , BMP_BGRa32    = 16          // 32-bit with alpha channel
  96.           
  97.                         // note below-16:32 selectors are not the base of a
  98.                         // selectorArray, therefore huge ptr arithmetic is not valid
  99.  
  100.           , BMP_IF09            = 17    // YVU9 with difference bits (16:32 selector,linear frame buffer)
  101.           , BMP_YVU9_PLANAR     = 18    // YVU9 (16:32 selector,linear frame buffer)
  102.           , BMP_YVU12_PLANAR    = 19    // YVU12 (16:32 selector,linear frame buffer)
  103.           , BMP_YVU9_PACKED     = 20    // YVU9 (16:32 selector,linear frame buffer)
  104.           , BMP_YVU12_PACKED    = 21    // YVU12 (16:32 selector,linear frame buffer)
  105.           , BMP_UYVY            = 22    // YUV 4:2:2 (16:32 selector,linear frame buffer) 
  106.           , BMP_YUV_411         = 23    // YUV_411 (16:32 selector,linear frame buffer) 
  107.           } ;
  108. typedef LONG ImageSequence ;
  109. // We regard as a limiting case a 1,600 x 1,200 screen with 3 bytes
  110. // per pixel and a pixel pitch that is a power of 2, thus 8,192.
  111. // This gives a bank break every 8 lines, for a total of 150 bank
  112. // breaks.
  113. #define MAXBANKBREAKS 150
  114. #if !defined _MATRIX
  115. #define _MATRIX
  116. typedef LONG LFRACT ;
  117. #define MAKELFRACT(value, fract) ((((DWORD)(fract))>>2) | (((DWORD)((WORD)(value))) << 30))
  118. typedef struct {                            // Hungarian: mtrx
  119.   struct {
  120.     LFIXED lfxCol1 ;
  121.     LFIXED lfxCol2 ;
  122.     LFRACT lfrCol3 ;
  123.   } Row[ 3] ;
  124. } MATRIX, FAR * LPMATRIX ;
  125. #endif                                      // !defined _MATRIX
  126. #define ostypeAPPL  QTFOURCC( 'a', 'p', 'p', 'l')
  127. #define ostypeCVID  QTFOURCC( 'c', 'v', 'i', 'd')
  128. #define ostypeDCMP  QTFOURCC( 'd', 'c', 'm', 'p')
  129. #define ostypeJPEG  QTFOURCC( 'j', 'p', 'e', 'g')
  130. #define ostypeRAW   QTFOURCC( 'r', 'a', 'w', ' ')
  131. #define ostypeRLE   QTFOURCC( 'r', 'l', 'e', ' ')
  132. #define ostypeRPZA  QTFOURCC( 'r', 'p', 'z', 'a')
  133. #define ostypeRT21  QTFOURCC( 'r', 't', '2', '1')
  134. #define ostypeIV31  QTFOURCC( 'i', 'v', '3', '1')
  135. #define ostypeIV32  QTFOURCC( 'i', 'v', '3', '2')
  136. #define ostypeSMC   QTFOURCC( 's', 'm', 'c', ' ')
  137.  
  138. /* Codec function selectors
  139.    Codec selectors 0-127 are reserved by Apple
  140.    Codec selectors 128-191 are subtype specific
  141.    Codec selectors 192-255 are vendor specific
  142.    Codec selectors 256-32767 are reserved by Apple
  143.    Negative selectors are reserved by the Component Manager
  144. */
  145. enum CODEC_SELECTOR { codecGetCodecInfo           =  0
  146.             , codecGetCompressionTime     =  1
  147.             , codecGetMaxCompressionSize  =  2
  148.             , codecPreCompress            =  3
  149.             , codecBandCompress           =  4
  150.             , codecPreDecompress          =  5
  151.             , codecBandDecompress         =  6
  152.             , codecCDSequenceBusy         =  7
  153.             , codecGetCompressedImageSize =  8
  154.             , codecGetSimilarity          =  9
  155.             , codecTrimImage              = 10
  156.             } ;
  157.  
  158.  
  159. typedef struct tagCODECCAPABILITIES {
  160.   LONG     lFlags ;
  161.   WORD     wWantedPixelSize ;
  162.   WORD     wExtendWidth ;                   // extra bytes after last row
  163.   WORD     wExtendHeight ;                  // number of rows per compress unit
  164.   WORD     wBandMin ;
  165.   WORD     wBandInc ;
  166.   WORD     wPad ;
  167.   WORD     wTime ;
  168.                         // new fields for Windows version
  169.   OPT_TYPE optt ;                           // the supported optimization
  170. } CODECCAPABILITIES, FAR * LPCODECCAPABILITIES ;
  171.  
  172. typedef struct tagMASKBITS  {
  173.   LPVOID lpBits ;                           // pointer to the bits
  174.   WORD wRowBytes ;                          // pixel pitch or BMP pitch
  175.   RECT rectBounds ;                         // clip rectangle
  176. } MASKBITS, FAR * LPMASKBITS ;
  177.  
  178. // flags for lFlags in CODECCAPABILITIES
  179. #define codecCanScale             (1L <<  0)
  180. #define codecCanMask              (1L <<  1)
  181. #define codecCanMatte             (1L <<  2)
  182. #define codecCanTransform         (1L <<  3)
  183. #define codecCanTransferMode      (1L <<  4)
  184. #define codecCanCopyPrev          (1L <<  5)
  185. #define codecCanSpool             (1L <<  6)
  186. #define codecCanClipVertical      (1L <<  7)
  187. #define codecCanClipRectangular   (1L <<  8)
  188. #define codecCanRemapColor        (1L <<  9)
  189. #define codecCanFastDither        (1L << 10)
  190. #define codecCanSrcExtract        (1L << 11)
  191. #define codecCanCopyPrevComp      (1L << 12)
  192. #define codecCanAsync             (1L << 13)
  193. #define codecCanMakeMask          (1L << 14)
  194. #define codecCanShift             (1L << 15)
  195.  
  196. // flags for lConditionFlags in CODECDECOMPRESSPARAMETERS
  197. #define codecConditionFirstBand         (1L <<  0)
  198. #define codecConditionLastBand          (1L <<  1)
  199. #define codecConditionCodecChangedMask  (1L << 31)
  200.  
  201. #if defined(_MSC_VER)
  202.     #pragma pack(1)
  203. #else
  204.     #error check structure packing
  205. #endif
  206.  
  207. typedef struct tagIMCLUTDATA {
  208.   short     sIndex ;
  209.   short     sRed ;
  210.   short     sGreen ;
  211.   short     sBlue ;
  212. } IMCLUTDATA, FAR * LPIMCLUTDATA ;
  213.  
  214. typedef struct tagIMAGECLUT {
  215.   short       clutID ;
  216.                       // remaining fields are optional
  217.   LONG        clutSeed ;
  218.   short       clutFlags ;
  219.   short       clutSize ;
  220.   IMCLUTDATA    clutData[ 1] ;
  221. } IMAGECLUT, FAR * LPIMAGECLUT ;
  222.  
  223. #pragma pack()
  224.  
  225. typedef struct tagFULLIMAGEDESCRIPTION {              
  226.     // These first fields must match IMAGEDESCRIPTION exactly (see qtw.h).
  227.     LONG  idSize;                       // structure size
  228.     DWORD CodecType;                    // 'rpza', 'jpeg', 'rle ', 'raw ', 'smc', 'cvid'
  229.     DWORD resvd1;                       //
  230.     WORD  resvd2;                       // always 0
  231.     WORD  dataRefIndex;                 // always 1
  232.     WORD  version;                      //
  233.     WORD  revLevel;                     //
  234.     DWORD vendor;                       // 'appl' or other vendor
  235.     DWORD temporalQuality;              //
  236.     DWORD spatialQuality;               //
  237.     WORD  width;                        // Source image width in pixels
  238.     WORD  height;                       // Source image height in pixels
  239.     LFIXED hRes;                        // Horizontal resolution (eg: 72.0)
  240.     LFIXED vRes;                        // Vertical resolution (eg: 72.0)
  241.     DWORD dataSize;                     // Memory required for image data
  242.     WORD  frameCount;                   // always 0
  243.     char  name[32];                     // Compression algorithm (eg: Animation)
  244.     WORD  depth;                        // Pixel depth of source image
  245.     WORD  clutID;                       // Macintosh ROM Color table ID
  246.   
  247.     // These last fields are additional data from the sample description.
  248.     // This is a variable length addition!
  249.     IMAGECLUT sampleClut;               // imageClut
  250.   
  251. } FULLIMAGEDESCRIPTION, FAR * LPFULLIMAGEDESCRIPTION ;
  252.  
  253. typedef struct tagCODECDECOMPRESSPARAMS {
  254.   LONG lSequenceID ;                        // number of first frame
  255.   ImageDescription FAR * lpim ;             // pointer to image description
  256.   LPVOID lpCompressed ;                     // pointer to compressed data
  257.   LONG lBufferSize ;                        // no image buffer size
  258.   LONG lFrameNumber ;                       // within the sequence
  259.   LONG lStartLine ;                         // starting line of band
  260.   LONG lStopLine ;                          // ending line of band
  261.   LONG lConditionFlags ;                    // how component has been called
  262.   LONG lCallerFlags ;                       // further control information
  263.   LPCODECCAPABILITIES lpCapabilities ;      // filled out by PreDecompress
  264.   LPVOID lpvProgressProc ;                  // no progress proc
  265.   LPVOID lpvCompletionProc ;                // no completion proc
  266.   LPVOID lpvDataProc ;                      // no data loading proc
  267.   HDC hdc ;                                 // instead of CGrafPtr
  268.   LPVOID lpUncompressed ;                   // pointer to offscreen buffer
  269.   LPMASKBITS lpMaskBits ;                   // mask bits structure
  270.   LPVOID lpMattePixMap ;                    // blend matte (unused)
  271.   RECT rectSample ;                         // subset of sample to decompress
  272.   LPMATRIX lpMatrix ;                       // target transformation matrix
  273.   BYTE bAccuracy ;                          // requested accuracy
  274.   BYTE bAlign ;                             // for alignment only
  275.   WORD wRop2 ;                              // usually R2_COPYPEN
  276.   WORD wMatrixType ;                        // identify 0.5X, 2X, 4X
  277.   RECT rectDest ;                           // destination rectangle
  278.   // new fields for Windows version
  279.   LONG lCompressedSize ;                    // size of compressed data
  280.   BMP_TYPE bmpt ;                           // BMP type
  281.   LPVOID lpDitherTable ;                    // pointer to dither table
  282.   WORD wClutSeed ;                          // track CLUT changes
  283.   OPT_TYPE optt ;                           // optimization type
  284.   HDWDISP lpvHardware ;                     // addr of adapter dispatch routine
  285.   LPWORD lpwBankBoundaries ;                // adapter's bank boundary table
  286.   LPWORD lpwBitSmear ;                      // bit smearing table
  287.   WORD wRowsPerFullSegment ;                // banding will obsolete this
  288.   LPVOID lpOffScreen ;                      // offscreen handling of bank splits
  289.   DWORD dwReserved[ 1] ;                    // room for expansion
  290.   OSType sourceDataType;
  291.   Handle sourceDataDesc;
  292.   LPVOID sourceDataPtr;    
  293. }  CODECDECOMPRESSPARAMS, FAR * LPCODECDECOMPRESSPARAMS ;
  294.  
  295. typedef struct tagCODECINFO {
  296.   char szTypeName[ 32] ;                    // name of codec type
  297.   WORD wVersion ;
  298.   WORD wRevLevel ;
  299.   DWORD dwVendor ;
  300.   DWORD dwDecompressFlags ;
  301.   DWORD dwCompressFlags ;
  302.   DWORD dwFormatFlags ;
  303.   BYTE bDecompressionAccuracy ;
  304.   WORD wCompressionSpeed ;
  305.   WORD wDecompressionSpeed ;
  306.   BYTE bCompressionLevel ;
  307.   BYTE bReserved ;
  308.   WORD wMinimumHeight ;
  309.   WORD wMinimumWidth ;
  310.   WORD wDecompressPipelineLatency ;
  311.   WORD wCompressPipelineLatency ;
  312.   DWORD dwPrivateData ;
  313. }  CODECINFO, FAR * LPCODECINFO ;
  314.  
  315. // flags for dwComponentFlags in ComponentDescription structure
  316. // flags for dwDecompressFlags and dwCompressFlags in CODECINFO
  317. // The depths refer to target depths supported.
  318. #define codecInfoDoes1           (1L <<  0)
  319. #define codecInfoDoes4           (1L <<  1)
  320. #define codecInfoDoes8           (1L <<  2)
  321. #define codecInfoDoes16          (1L <<  3)
  322. #define codecInfoDoes24          (1L <<  4)
  323. #define codecInfoDoes32          (1L <<  5)
  324. #define codecInfoDoesDither      (1L <<  6)
  325. #define codecInfoDoesStretch     (1L <<  7)
  326. #define codecInfoDoesShrink      (1L <<  8)
  327. #define codecInfoDoesMask        (1L <<  9)
  328. #define codecInfoDoesTemporal    (1L << 10)
  329. #define codecInfoDoesDouble      (1L << 11)
  330. #define codecInfoDoesQuad        (1L << 12)
  331. #define codecInfoDoesHalf        (1L << 13)
  332. #define codecInfoDoesQuarter     (1L << 14)
  333. #define codecInfoDoesRotate      (1L << 15)
  334. #define codecInfoDoesHorizFlip   (1L << 16)
  335. #define codecInfoDoesVertFlip    (1L << 17)
  336. #define codecInfoDoesSkew        (1L << 18)
  337. #define codecInfoDoesBlend       (1L << 19)
  338. #define codecInfoDoesWarp        (1L << 20)
  339. #define codecInfoDoesRecompress  (1L << 21)
  340. #define codecInfoDoesSpool       (1L << 22)
  341.  
  342. // flags for dwFormatFlags in CODECINFO
  343. // The depths refer to source depths supported.
  344. #define codecInfoDepth1          (1L <<  0)
  345. #define codecInfoDepth2          (1L <<  1)
  346. #define codecInfoDepth4          (1L <<  2)
  347. #define codecInfoDepth8          (1L <<  3)
  348. #define codecInfoDepth16         (1L <<  4)
  349. #define codecInfoDepth24         (1L <<  5)
  350. #define codecInfoDepth32         (1L <<  6)
  351. #define codecInfoDepth33         (1L <<  7)
  352. #define codecInfoDepth34         (1L <<  8)
  353. #define codecInfoDepth36         (1L <<  9)
  354. #define codecInfoDepth40         (1L << 10)
  355. #define codecInfoStoresClut      (1L << 11)
  356. #define codecInfoDoesLossless    (1L << 12)
  357. #define codecInfoSeqSensitive    (1L << 13)
  358.  
  359. // Functions
  360. #if defined __cplusplus
  361. extern "C" {
  362. #endif
  363. ComponentResult QTAPI cfBandDecompress( STKOFF_CMP so
  364.                       , LPVOID lpvStorage
  365.                       , LPCODECDECOMPRESSPARAMS lpdecomp
  366.                       ) ;
  367. ComponentResult QTAPI cfCanDoSelect( STKOFF_CMP so, LONG lFunctionSelector) ;
  368. ComponentResult QTAPI cfCloseSelect( STKOFF_CMP so, ComponentInstance ci) ;
  369. ComponentResult QTAPI cfGetCodecInfo( STKOFF_CMP so
  370.                     , LPVOID lpvStorage
  371.                     , LPCODECINFO lpinfo
  372.                     ) ;
  373. ComponentResult QTAPI cfOpenSelect( STKOFF_CMP so, ComponentInstance ci) ;
  374. ComponentResult QTAPI cfPreDecompress( STKOFF_CMP so
  375.                      , LPVOID lpvStorage
  376.                      , LPCODECDECOMPRESSPARAMS lpdecomp
  377.                      ) ;
  378. ComponentResult QTAPI cfRegisterSelect( STKOFF_CMP so, ComponentInstance ci) ;
  379. ComponentResult QTAPI cfSequenceBusy( STKOFF_CMP so
  380.                     , LPVOID lpvStorage
  381.                     , ImageSequence seq
  382.                     ) ;
  383. ComponentResult QTAPI cfTargetSelect( STKOFF_CMP so, ComponentInstance ci) ;
  384. ComponentResult QTAPI cfVersionSelect( STKOFF_CMP so, ComponentInstance ci) ;
  385.  
  386. DWORD QTAPI CodecEntry( VOID) ;
  387. WORD QTAPI Flip16( WORD wValue) ;
  388. VOID QTAPI Flip16Many( LPVOID lpSource, DWORD dwNbrWords) ;
  389. LONG QTAPI Flip32( LONG lValue) ;
  390. VOID QTAPI Flip32Many( LPVOID lpSource, DWORD dwNbrDwords) ;
  391. BOOL QTAPI FreeMemory( LPVOID lpvMem) ;
  392. LPVOID QTAPI GetMemory( LONG lSize) ;
  393. LPVOID QTAPI ReallocateMemory( LPVOID lpvMem, LONG lSize) ;
  394. #ifndef _WIN32
  395.     VOID QTAPI CopyMemory( HPVOID hpvDest, HPVOID hpvSource, LONG cbCopy) ;
  396. #endif
  397. OSType FAR PASCAL THNGIDENTIFY( LPCID FAR *lplpcid) ;
  398. VOID QTAPI VidComputeBankBoundaries1( LPWORD lpSourceTable
  399.                     , LPWORD lpTargetTable
  400.                     , WORD wLeft
  401.                     , WORD wTop
  402.                     , WORD wRight
  403.                     , WORD wBottom
  404.                     ) ;
  405. VOID QTAPI VidComputeBankBoundaries2( LPWORD lpSourceTable
  406.                     , LPWORD lpTargetTable
  407.                     , WORD wLeft
  408.                     , WORD wTop
  409.                     , WORD wRight
  410.                     , WORD wBottom
  411.                     ) ;
  412. VOID QTAPI VidComputeBankBoundaries4( LPWORD lpSourceTable
  413.                     , LPWORD lpTargetTable
  414.                     , WORD wLeft
  415.                     , WORD wTop
  416.                     , WORD wRight
  417.                     , WORD wBottom
  418.                     ) ;
  419. VOID QTAPI VidComputeBankBoundaries81( LPWORD lpSourceTable
  420.                      , LPWORD lpTargetTable
  421.                      , WORD wLeft
  422.                      , WORD wTop
  423.                      , WORD wRight
  424.                      , WORD wBottom
  425.                      ) ;
  426. VOID QTAPI VidComputeBankBoundaries82( LPWORD lpSourceTable
  427.                      , LPWORD lpTargetTable
  428.                      , WORD wLeft
  429.                      , WORD wTop
  430.                      , WORD wRight
  431.                      , WORD wBottom
  432.                      ) ;
  433. #if defined __cplusplus
  434. }                                           // defined __cplusplus
  435. #endif
  436.  
  437. #endif                                      // !defined __QTCODEC_H
  438.